import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * 作者：Sky
 * QQ：2780619724
 * 此类用于获取连接在电脑上的手机设备序列号，并返回List<String>
 *
 */

public class GetSNList {

    Process process = null;
    List<String> processList = new ArrayList<String>();
    List<String> SNList = new ArrayList<String>();
    String cmd="adb devices";

    public List<String> getSNList(){
        try {
            process = Runtime.getRuntime().exec(cmd);
            //Thread.sleep(5000);
            BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line = "";
            while ((line = input.readLine()) != null) {
                processList.add(line);
            }
            input.close();

            for(int i=1; i<=processList.size()-1;i++){
                String[] SN = processList.get(i).split("\t");
                SNList.add(SN[0]);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        return SNList;
    }
}
